<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0 ;
            padding: 0 ;
        }
        div{
            margin: 20 0;
            text-align: center;
        }
        h1{
            margin: 0 auto;
            text-align: center;
        }
    </style>
</head>

<body>
    <h1>登录</h1>
    <div>
        <input type="text" name="user" id="user" placeholder="用户名">
    </div>
    <div>
        <input type="password" name="pass" id="pass" placeholder="密码">
    </div>
    <div>
        <button class="button">登录</button>   <button class="but">注册</button>
    </div>
</body>

</html>
<script src="../js/ajax.js"></script>
<script>
    function $(e){return document.querySelector(e)}
    $(".button").onclick=()=>{
    
      obj.get({
          url:"/login",
          text:{
            user: $("#user").value,
            pass: $("#pass").value,

          },
          callback
      })
       
    }
    $(".but").onclick=()=>{
        location.href = "http://localhost:3000/public/cook/html/registry.html"
     
  }
   function callback(data){
  
       switch(data){
        case "001":alert("登录成功");
        location.href = "http://localhost:3000/public/cook/html/index.html"
        break
        case "002":alert("密码错误");break
        case "003":alert("账号不存在");break
       }
     
    }
</script>